package com.woniuxy.controller;

import com.woniuxy.common.Result;
import com.woniuxy.common.StatusCode;
import com.woniuxy.dto.DtoProjectInfoOfClassify;
import com.woniuxy.dto.DtoProjectInfoOfDegree;
import com.woniuxy.dto.DtoProjectInfoOfState;
import com.woniuxy.service.RecordbugService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;

/**
 * @ClassName ChartController
 * @Description 项目缺陷图表统计系统
 * @Author Zcd
 * @Version 1.0
 **/

@RestController
@RequestMapping("/chart")
@Api(tags = "图表统计系统")
public class ChartController {

    @Resource
    private RecordbugService recordbugService;

    @GetMapping("allProject")
    @ApiOperation("获取当前所有项目种类")
    /**
    * @Author： Zcd
    * @Description: 获取当前所有项目
    * @Param: []
    * @Return: com.woniuxy.common.Result
    */
    public Result getAllProject() {
        ArrayList<Integer> allProjectClass = recordbugService.getAllProjectClass();
        return new Result(true, StatusCode.OK, "操作成功", allProjectClass);
    }

    @GetMapping("getProjectInfoOfClassify")
    @ApiOperation("获取该项目各缺陷分类数量统计")
    /**
    * @Author： Zcd
    * @Description: 获取该项目各缺陷分类数量统计
    * @Param: [projectId]
    * @Return: com.woniuxy.common.Result
    */
    public Result getProjectInfoOfClassify(int projectId) {
        DtoProjectInfoOfClassify dtoProjectInfoOfClassify = recordbugService.countProjectClassify(projectId);
        return new Result(true, StatusCode.OK, "操作成功", dtoProjectInfoOfClassify);
    }

    @GetMapping("getProjectInfoOfState")
    @ApiOperation("获取该项目各缺陷状态数量统计")
    /**
    * @Author： Zcd
    * @Description: 获取该项目各缺陷状态数量统计
    * @Param: [projectId]
    * @Return: com.woniuxy.common.Result
    */
    public Result getProjectInfoOfState(int projectId) {
        DtoProjectInfoOfState dtoProjectInfoOfState = recordbugService.countProjectState(projectId);
        return new Result(true, StatusCode.OK, "操作成功", dtoProjectInfoOfState);
    }

    @GetMapping("getProjectInfoOfDegree")
    @ApiOperation("获取该项目各缺陷严重程度数量统计")
    /**
     * @Author： Zcd
     * @Description: 获取该项目各缺陷严重程度数量统计
     * @Param: [projectId]
     * @Return: com.woniuxy.common.Result
     */
    public Result getProjectInfoOfDegree(int projectId) {
        DtoProjectInfoOfDegree dtoProjectInfoOfDegree = recordbugService.countProjectDegree(projectId);
        return new Result(true, StatusCode.OK, "操作成功", dtoProjectInfoOfDegree);
    }

}
